package com.qdlg.tating.cotroller;

import com.qdlg.tating.pojo.User;
import com.qdlg.tating.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Administrator on 2016/1/15 0015.
 */
@Controller
public class UserController {
    @Resource(name="userService")
    IUserService userService;


    /***
     * 用于用户登陆，密码是经过加密过来的，要与数据库中保存的密码比较，两者都是加了密的
     *
     * @param req
     * @param resp
     * @return 跳转界面
     */
    @RequestMapping("/userLogin")
    public String Test(HttpServletRequest req,HttpServletResponse resp) {
        String username = req.getParameter("username");

        String password = req.getParameter("password");

        User user = new User();

        user.setUsername(username);
        user.setPassword(password);
        if (userService.validateUser(user) != null) {
            return "index";
        } else {
            return "fail";
        }
    }
}
